package com.project.server;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class MyServer {

    public MyServer(){
        try {
            //开启服务器，并开放8088端口
            ServerSocket serverSocket = new ServerSocket(8088);

            while(true){
                //循环监听端口，如果有客户端连接到服务器。会将连接信息封装成socket对象。以便进行数据交互
                Socket socket = serverSocket.accept();//线程阻塞
                new SocketThread(socket);
            }

        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
    public static void main(String[] args) {
        new MyServer();
    }
}
